// 这个文件是用来书写api接口请求函数的文件
// 以后我们请求获取数据,每个接口都对应一个函数去发请求

// 请求获取三极分类列表数据的函数
import Ajax from './ajax';
import mockAjax from './mockAjax'

export const reqCategoryList = () => {
    return Ajax({
        url: '/product/getBaseCategoryList',
        method: 'get'
    })
}

// 请求获取mock的接口   轮播图
export const reqBannerList = () => {
    return mockAjax({
        url: '/banner',
        method: 'get'
    })
}

export const reqFloorList = () => {
    return mockAjax({
        url: '/floor',
        method: 'get'
    })
}

// /api/list
//   post

//   请求获取商品列表
export const reqGoodsListInfo = (searchParams) => {
    return Ajax({
        url: '/list',
        method: 'post',
        data: searchParams
    })
}


export const reqGoodsDetailInfo = (skuId) => {
    return Ajax({
        url: `/item/${skuId}`,
        method: 'get'
    })
}

// 请求添加购物车(修改购物车信息)
export const reqAddOrUpdateShopCart = (skuId, skuNum) => {
    return Ajax({
        url: `/cart/addToCart/${skuId}/${skuNum}`,
        method: 'pOst'
    })
}


// 购物车商品列表
//   /api/cart/cartList
export const reqShopCartList = () => {
    return Ajax({
        url: '/cart/cartList',
        method: 'get'
    })
}

// 修改一个
// /api/cart/checkCart/{skuID}/{isChecked}
// GET
export const reqUpdateOneIsChecked = (skuId, isChecked) => {
    return Ajax({
        url: `/cart/checkCart/${skuId}/${isChecked}`,
        method: 'get'
    })
}

// 修改多个
export const reqUpdateAllIsChecked = (isChecked, skuIds) => {
    return Ajax({
        url: `/cart/batchCheckCart/${isChecked}`,
        method: 'post',
        data: skuIds
    })
}

// 删除单个购物车
export const reqDeleteOneShopCart = (skuId) => {
    return Ajax({
        url: `/cart/deleteCart/${skuId}`,
        method: 'delete'
    })
}

// 删除多个购物车 
export const reqDeleteAllShopCart = (skuIds) => {
    return Ajax({
        url: '/cart/batchDeleteCart',
        method: 'delete',
        data: skuIds
    })
}


// /api/user/passport/sendCode/{phone}
// get
// 获取验证码
export const reqGetCode = (phone) => {
    return Ajax({
        url: `/user/passport/sendCode/${phone}`,
        method: 'get'
    })
}

// /api/user/passport/register
// 注册用户
export const reqUserRegister = (userInfo) => {
    return Ajax({
        url: '/user/passport/register',
        method: 'post',
        data:userInfo
    })
}
// 登录用户

export const reqUserLogin = (userInfo) => {
    return Ajax({
        url: '/user/passport/login',
        method: 'post',
        data:userInfo
    })
}
// 获取用户信息
export const reqGetUserInfo = ()=>{
    return Ajax({
        url:'/user/passport/auth/getUserInfo',
        method:'get'
    })
}

//  请求退出登录
// /api/user/passport/logout
export const reqUserLogout = ()=>{
    return Ajax({
        url:'/user/passport/logout',
        method:'get'
    })
}

// /api/user/userAddress/auth/findUserAddressList
// 获取用户收货地址信息
// get

export const reqUserAddressList = ()=>{
    return Ajax({
        url:'/user/userAddress/auth/findUserAddressList',
        method:'get'
    })
}

// /api/order/auth/trade
// 获取用户订单交易信息
export const reqTradeInfo = ()=>{
    return Ajax({
        url:'/order/auth/trade',
        method:'get'
    })
}

// 获取提交订单信息
//  /api/order/auth/submitOrder?tradeNo={tradeNo}
export const reqSubmitOrder = (tradeNo,tradeInfo)=>{
    return Ajax({
        url:`order/auth/submitOrder?tradeNo=${tradeNo}`,
        method:'post',
        data:tradeInfo
    })
}

// 获取支付信息
// /api/payment/weixin/createNative/{orderId}
export const reqPayInfo = (orderId)=>{
    return Ajax({
        url:`/payment/weixin/createNative/${orderId}`,
        method:'get'
    })
}

//  请求获取支付状态
// /api/payment/weixin/queryPayStatus/{orderId}
export const reqPayStatus = (orderId)=>{
    return Ajax({
        url:`/payment/weixin/queryPayStatus/${orderId}`,
        method:'get'
    })
}